package utils;

import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
import java.util.Date;
import java.util.Vector;

public class ListFiles {

	public static void list(boolean recursive,File dir,Vector fileArray){
		FileFilter select = new FileListFilter();
		
		File[] contents = dir.listFiles(select);
		if (contents != null) {
		      for (File file : contents) {
		    	  if(file.isDirectory())
		    		  list(true,file,fileArray);
		    	  else
		    	  {
		    		  fileArray.add(file);
		        System.out.println("movie file found: " +file );
		    	  }
		      }
		    } else {
//		      System.out.println(dir.getName() + " is not a directory");
		    }
	}
	
	
}
class FileListFilter implements FileFilter {


	private final String[] okFileExtensions = 
		    new String[] {"mkv", "avi", "rmvb"};

		  public boolean accept(File file)
		  {
		    for (String extension : okFileExtensions)
		    {
		      if (file.getName().toLowerCase().endsWith(extension)||file.isDirectory())
		      {
		        return true;
		      }
		    }
		    return false;
		  }
}